namespace player
{
    public class RunState : State
    {
        public override void Process()
        {
            base.Process();

            if (!player.IsGroundDetected() && player.TryChangeState(StateCode.Fall)) return;
            if (player.input.GamePlay.Jump.WasPressedThisFrame() && player.TryChangeState(StateCode.Jump)) return;
            if (player.input.GamePlay.Attack.WasPressedThisFrame() && player.TryChangeState(StateCode.Attack)) return;
            if (player.moveInput.x == 0 && player.TryChangeState(StateCode.Idle)) return;
           
            if (player.IsWallDetected() && (player.moveInput.x * player.FacingDirection() > 0))
                player.ResetVelocity();
            else
                player.SetVelocity(player.moveInput.x * player.moveSpeed, 0);
        }
    }
}
